home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE21 / EX10.C < prev    next >
C/C++ Source or Header  |  1995-05-29  |  4KB  |  81 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_DESTROY:
  8.                PostQuitMessage( 0 );
  9.                break;
  10.          case WM_COMMAND:
  11.                switch ( LOWORD( wParam ) )
  12.                {
  13.                      case IDM_TEST:  // Display system and user defaults.
  14.                      {
  15.                            LCID   lcidDefault;
  16.                            LANGID langidDefault;
  17.                            char   szMessage[128];
  18.                            char   szDefaultLanguage[64];
  19.                            char   szDefaultNativeLanguage[64];
  20.                            char   szDefaultCountry[64];
  21.                            char   szDefaultNativeCountry[64];
  22.  
  23.                            HDC hDC = GetDC( hWnd );
  24.  
  25.                            // Get system default information.
  26.                            lcidDefault = GetSystemDefaultLCID( );
  27.                            langidDefault = GetSystemDefaultLangID( );
  28.                            VerLanguageName( langidDefault, szDefaultLanguage, 63 );
  29.                            GetLocaleInfo( lcidDefault, LOCALE_SNATIVELANGNAME,
  30.                                           szDefaultNativeLanguage, 63 );
  31.                            GetLocaleInfo( lcidDefault, LOCALE_SENGCOUNTRY,
  32.                                           szDefaultCountry, 63 );
  33.                            GetLocaleInfo( lcidDefault, LOCALE_SCOUNTRY,
  34.                                           szDefaultNativeCountry, 63 );
  35.  
  36.                            wsprintf( szMessage,
  37.                                      "System Language: %X is %s or %s (native) ",
  38.                                      langidDefault, szDefaultLanguage,
  39.                                      szDefaultNativeLanguage );
  40.                            TextOut( hDC, 0, 0, szMessage, lstrlen( szMessage ) );
  41.                            wsprintf( szMessage,
  42.                                      "System Locale: %X is %s or %s (native) ",
  43.                                      lcidDefault, szDefaultCountry,
  44.                                      szDefaultNativeCountry );
  45.                            TextOut( hDC, 0, 20, szMessage, lstrlen( szMessage ) );
  46.  
  47.                            // Get user default information.
  48.                            lcidDefault = GetUserDefaultLCID( );
  49.                            langidDefault = GetUserDefaultLangID( );
  50.                            VerLanguageName( langidDefault, szDefaultLanguage, 63 );
  51.                            GetLocaleInfo( lcidDefault, LOCALE_SNATIVELANGNAME,
  52.                                           szDefaultNativeLanguage, 63 );
  53.                            GetLocaleInfo( lcidDefault, LOCALE_SENGCOUNTRY,
  54.                                           szDefaultCountry, 63 );
  55.                            GetLocaleInfo( lcidDefault, LOCALE_SCOUNTRY,
  56.                                           szDefaultNativeCountry, 63 );
  57.  
  58.                            wsprintf( szMessage,
  59.                                      "User Language: %X is %s or %s (native) ",
  60.                                      langidDefault, szDefaultLanguage,
  61.                                      szDefaultNativeLanguage );
  62.                            TextOut( hDC, 0, 40, szMessage, lstrlen( szMessage ) );
  63.                            wsprintf( szMessage,
  64.                                      "User Default Locale: %X is %s or %s (native) ",
  65.                                      lcidDefault, szDefaultCountry,
  66.                                      szDefaultNativeCountry );
  67.                            TextOut( hDC, 0, 60, szMessage, lstrlen( szMessage ) );
  68.  
  69.                            ReleaseDC( hWnd, hDC );
  70.                      }
  71.                      break;
  72.                      case IDM_EXIT:
  73.                            DestroyWindow( hWnd );
  74.                            break;
  75.                }
  76.                break;
  77.          default:
  78.                return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  79.    }
  80.    return( NULL );
  81. }